package wpp

import (
	"errors"
	"github.com/gogf/gf/frame/g"
	"websocket/app/service/websocket/logic/common"
)

func Ping(ctx *common.WorkContext) (g.Map, error) {
	return g.Map{
		"ping": "pong",
	}, nil
}

func Go(ctx *common.WorkContext) (g.Map, error) {
	return g.Map{
		"go": "run",
	}, nil
}

func Sync(ctx *common.WorkContext) (g.Map, error) {
	return nil, errors.New("sync error")
}

func Point(ctx *common.WorkContext) (g.Map, error) {
	panic("point panic")
	return nil, errors.New("point error")
}

func My(ctx *common.WorkContext) (g.Map, error) {
	unique := ctx.Data.Unique
	jsonstr := ctx.Data.Original
	return g.Map{
		"unique": unique,
		"jsonstr": jsonstr,
	}, nil
}

func Test2(ctx *common.WorkContext) (g.Map, error) {
	return g.Map{
		"str": "test2",
	}, nil
}

func Test3(ctx *common.WorkContext) (g.Map, error) {
	return g.Map{
		"str": "test2",
	}, nil
}